﻿using System;
using System.Collections.Generic;
using NDBGen.Plugins;

namespace NDBGen.Tests
{
    public abstract class GeneratorUnitTestBase<TPluginData, TGenerator> : UnitTestBase<TPluginData>
        where TPluginData : IPluginData
        where TGenerator : IFileGenerator<TPluginData>, new()
    {
        protected TGenerator GetGenerator( out ParsedInput parsedInput, String schemaInput, String dataInput)
        {
            return GetGenerator(out parsedInput, schemaInput, new Dictionary<String, String[]> { { "test", new String[] { dataInput } } });
        }

        protected TGenerator GetGenerator(out ParsedInput parsedInput, String schemaInput, IDictionary<String, String[]> dataInput = null)
        {
            parsedInput = ParsedInputUtil.CreateParsedInput(schemaInput, Environment.CurrentDirectory, dataInput);
            var generator = new TGenerator();

            var pluginData = this.GetPluginData(parsedInput);
            generator.Init(pluginData);

            return generator;
        }
    }
}
